package phidgetmotion.gui.util;

import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

/**
 * @author Thomas
 *
 */
public class IntegerDocument extends PlainDocument
{
	private static final long serialVersionUID = 1L;
	
	@Override
	public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
	{
		char c;
		for (int i = 0; i < str.length(); i++)
		{
			c = str.charAt(i);
			if (c < '0' || c > '9') return;
		}
		super.insertString(offset, str, a);
	}
}
